
#ifndef __I2C_H__
#define __I2C_H__

#include "stm32f10x_gpio.h"
#include "stm32f10x_rcc.h"
#include "delay.h"

#define PIN_SCL GPIO_Pin_6
#define PIN_SDA GPIO_Pin_7
#define GPIO_SCL GPIOB
#define GPIO_SDA GPIOB

#define RCC_SCL RCC_APB2Periph_GPIOB
#define RCC_SDA RCC_APB2Periph_GPIOB   

#define SCL_H GPIO_SetBits(GPIO_SCL, PIN_SCL)
#define SCL_L  GPIO_ResetBits(GPIO_SCL, PIN_SCL)

#define sda_read() GPIO_ReadInputDataBit(GPIO_SDA, PIN_SDA)

void i2c_init(void);
void i2c_start(void);
void i2c_stop(void);
void i2c_send_byte(uint8_t data);
uint8_t i2c_recv_byte(void);
void i2c_send_ack(uint8_t ack);
uint8_t i2c_recv_ack(void);


#endif /* __UART_H__ */
